package com.example.shiwu.util;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.util.Log;

public class WifiReceiver extends BroadcastReceiver {
    private static final String TAG = "WifiReceiver";
    public static Boolean bool = true;
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)) {
            int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, -1);
            switch (wifiState) {
                case WifiManager.WIFI_STATE_ENABLED:
                    Log.d(TAG, "WiFi已连接");
                    break;
                case WifiManager.WIFI_STATE_DISABLED:
                    Log.d(TAG, "WiFi已断开");
                    bool = false;
                    break;
            }
        }
    }
}
